#ifndef RADICAL_SEMANTIC_H
#define RADICAL_SEMANTIC_H

#include <string>
#include <vector>
#include <map>

class SemanticVector {
private:
    std::vector<double> values;

public:
    SemanticVector() = default;
    SemanticVector(const std::vector<double>& vals) : values(vals) {}
    
    // 向量运算
    SemanticVector operator+(const SemanticVector& other) const;
    SemanticVector operator*(double scalar) const;
    
    // 余弦相似度
    double cosineSimilarity(const SemanticVector& other) const;
    
    // 获取向量维度
    size_t size() const { return values.size(); }
    
    // 获取指定维度的值
    double operator[](size_t index) const { return values[index]; }
};

class RadicalSemantic {
private:
    static std::map<std::string, SemanticVector> radicalSemantics;
    static bool initialized;

public:
    // 初始化字根语义库
    static void initialize();
    
    // 获取字根的语义向量
    static SemanticVector getSemanticVector(const std::string& radical);
    
    // 查找语义相关的字根
    static std::vector<std::string> findSemanticallyRelated(const std::string& radical);
    
    // 计算字根间的语义距离
    static double semanticDistance(const std::string& radical1, const std::string& radical2);
};

#endif // RADICAL_SEMANTIC_H